﻿// Decompiled with JetBrains decompiler
// Type: System.Web.Razor.Generator.SetLayoutCodeGenerator
// Assembly: System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// MVID: 682513D6-F37E-48AC-9909-F3EE103CFF14
// Assembly location: D:\Project\Idea\无人机外网\uav\客户端工程\排查工具\bin\Release\System.Web.Razor.dll

using System.CodeDom;
using System.Web.Razor.Parser.SyntaxTree;

namespace System.Web.Razor.Generator
{
  /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Represents a code generator that sets layout for the web Razor.</summary>
  public class SetLayoutCodeGenerator : SpanCodeGenerator
  {
    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Initializes a new instance of the <see cref="T:System.Web.Razor.Generator.SetLayoutCodeGenerator" /> class.</summary>
    /// <param name="layoutPath">The layout path.</param>
    public SetLayoutCodeGenerator(string layoutPath) => this.LayoutPath = layoutPath;

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets or sets the path of the layout code.</summary>
    /// <returns>The path of the layout code.</returns>
    public string LayoutPath { get; set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Generates a layout code.</summary>
    /// <param name="target">The target where to generate the code.</param>
    /// <param name="context">The code generator context.</param>
    public override void GenerateCode(Span target, CodeGeneratorContext context)
    {
      if (context.Host.DesignTimeMode || string.IsNullOrEmpty(context.Host.GeneratedClassContext.LayoutPropertyName))
        return;
      context.TargetMethod.Statements.Add((CodeStatement) new CodeAssignStatement((CodeExpression) new CodePropertyReferenceExpression((CodeExpression) null, context.Host.GeneratedClassContext.LayoutPropertyName), (CodeExpression) new CodePrimitiveExpression((object) this.LayoutPath)));
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Returns a string representation of this current instance.</summary>
    /// <returns>A string representation of this current instance.</returns>
    public override string ToString() => "Layout: " + this.LayoutPath;

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Determines whether the specified object is equal to the current object.</summary>
    /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
    /// <param name="obj">The object to compare to.</param>
    public override bool Equals(object obj) => obj is SetLayoutCodeGenerator layoutCodeGenerator && string.Equals(layoutCodeGenerator.LayoutPath, this.LayoutPath, StringComparison.Ordinal);

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Retrieves a hash code for this current instance.</summary>
    /// <returns>A hash code for this current instance.</returns>
    public override int GetHashCode() => this.LayoutPath.GetHashCode();
  }
}
